<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="utf-8">
    <title>首页</title>
    <link rel="stylesheet" href="/static/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="/static/css/home.css" media="all">
    <link rel="stylesheet" href="/static/css/home1.css" media="all">
    <link rel="stylesheet" href="/static/layui/css/modules/layer/default/layer.css" media="all">
    <script src="https://hm.baidu.com/hm.js"></script>
    <script src="/static/js/echarts.simple.min.js"></script>
    <script type="text/javascript" src="/static/js/jquery.min.js"></script>
    <script type="text/javascript" src="/static/layui/lay/modules/layer.js"></script>
</head>
<body>
<div id="layerDemo" class="layui-fluid" style="background: rgb(242,242,242)">
    <fieldset class="layui-elem-field layui-field-title">
        <legend>当前通话----如需测试请拨打02085733505</legend>
    </fieldset>
{{if eq .count 0 }}
    <div class="layui-card" style="padding: 20px">暂无通话。。。
    </div>
{{end}}
    <div class="layui-col-sm12">
        <div class="layui-card">
{{/*            <button type="button" class="layui-btn layui-btn-normal number_btn">0、8001</button>*/}}

            {{range  $index, $elem := .runtime}}
            <button type="button" class="layui-btn layui-btn-normal number_btn">{{$index}}、{{$elem.number}}</button>
        {{end}}
            <button type="button" class="layui-btn" id="test1">
                <i class="layui-icon">&#xe67c;</i>上传话术文件
            </button>
            <button type="button" class="layui-btn" id="test2">
                <i class="layui-icon">&#xe67c;</i>上传录音文件
            </button>
        </div>
    </div>
    <div class="layui-row layui-col-space15">
        <div class="layui-col-sm8 layui-col-md4">
            <div class="layui-card">
                <div class="layui-card-header">
                    禁忌词语
                    <input type="text" id="fail" class="layuiadmin-badge" style="position: absolute;right: 100px">
                    <a class="layui-badge layui-bg-orange layuiadmin-badge" style="right: 58px"
                       onclick="failAdd()">添加</a>
                    <a class="layui-badge layui-bg-orange layuiadmin-badge" href="/keywords/list?type=1">列表</a>
                </div>
            </div>
        </div>
        <div class="layui-col-sm8 layui-col-md4">
            <div class="layui-card">
                <div class="layui-card-header">
                    常规词语
                    <input type="text" id="good" class="layuiadmin-badge" style="position: absolute;right: 100px">
                    <a class="layui-badge layui-bg-orange layuiadmin-badge" style="right: 58px"
                       onclick="goodAdd()">添加</a>
                    <a class="layui-badge layui-bg-orange layuiadmin-badge" href="/keywords/list?type=2">列表</a>
                </div>
            </div>
        </div>
        <div class="layui-col-sm8 layui-col-md4">
            <div class="layui-card">
                <div class="layui-card-header">
                    普通词语
                    <input type="text" id="common" class="layuiadmin-badge" style="position: absolute;right: 100px">
                    <a class="layui-badge layui-bg-orange layuiadmin-badge" style="right: 58px"
                       onclick="commonAdd()">添加</a>
                    <a class="layui-badge layui-bg-orange layuiadmin-badge" href="/keywords/list?type=3">列表</a>
                </div>
            </div>
        </div>
        <div class="layui-col-sm6 layui-col-md4">
            <div class="layui-card">
                <div class="layui-card-header">
                    常规词次数
                    <span class="layui-badge layui-bg-blue layuiadmin-badge">优</span>
                </div>
                <div class="layui-card-body layuiadmin-card-list" onclick="liuliangTap()">
                    <p class="layuiadmin-big-font">{{.fine_count}}</p>
                    <p>
                        当日出现次数
                        <span class="layuiadmin-span-color">{{.fine_count}}<i
                                class="layui-inline layui-icon layui-icon-flag"></i></span>
                    </p>
                </div>
            </div>
        </div>
        <div class="layui-col-sm6 layui-col-md4">
            <div class="layui-card">
                <div class="layui-card-header">
                    禁忌词次数
                    <span class="layui-badge layui-bg-cyan layuiadmin-badge">危</span>
                </div>
                <div class="layui-card-body layuiadmin-card-list" onclick="weixianTap()">
                    <p class="layuiadmin-big-font">{{.fail_count}}</p>
                    <p>
                        当日出现次数
                        <span class="layuiadmin-span-color">{{.fail_count}}</span>
                    </p>
                </div>
            </div>
        </div>
        <div class="layui-col-sm6 layui-col-md4">
            <div class="layui-card">
                <div class="layui-card-header">
                    呼叫次数
                    <span class="layui-badge layui-bg-green layuiadmin-badge">日</span>
                </div>
                <div class="layui-card-body layuiadmin-card-list">

                    <p class="layuiadmin-big-font">{{.all}}</p>
                    <p>
                        当日呼叫次数
                        <span class="layuiadmin-span-color">{{.all}}</span>
                    </p>
                </div>
            </div>
        </div>
    {{/*<div class="layui-col-sm6 layui-col-md3">*/}}
    {{/*<div class="layui-card">*/}}
    {{/*<div class="layui-card-header">*/}}
    {{/*转换率*/}}
    {{/*<span class="layui-badge layui-bg-orange layuiadmin-badge">日</span>*/}}
    {{/*</div>*/}}
    {{/*<div class="layui-card-body layuiadmin-card-list">*/}}
    {{/*<p class="layuiadmin-big-font" id="zhuan"></p>*/}}
    {{/*<p>*/}}
    {{/*当日呼叫转换率*/}}
    {{/*<span class="layuiadmin-span-color" id="zhuan1"></span>*/}}
    {{/*</p>*/}}
    {{/*</div>*/}}
    {{/*</div>*/}}
    {{/*</div>*/}}
    </div>
</div>
<script src="/static/layui/layui.js"></script>
<script type="text/javascript">
    layui.use(['flow', 'upload'], function () {
        var $ = layui.jquery;
        $('#layerDemo .number_btn').on('click', function (data) {
            console.log($(this).text(),"=====")
            var uid = $(this).text().split("、")[0]
            var runtimes = {{.runtime}}
                    console.log(runtimes[uid].uuid)
            layer.open({
                type: 2 //此处以iframe举例
                , title: '当前运行中的电话-'
                // ,title: '当前运行中的电话-'+str.split("、")[1]
                , area: ['100%', '100%']
                , shade: 0
                , maxmin: true
                // ,content: '../cdr/flowcdr?callid=89e6ef8c-aebf-11e9-b629-1d115420be52'
                , content: '../cdr/flowcdr?callid=' + runtimes[uid].uuid
                , zIndex: layer.zIndex //重点1
                , success: function (layero) {
                    layer.setTop(layero); //重点2
                }
            });
            // window.location.href="flowcdr?callid=94e0bab6-fd0e-11e8-8fee-935ff44a66ec"
        });
        var upload = layui.upload;

        //执行实例
        upload.render({
            elem: '#test1' //绑定元素
            , url: '/home/import' //上传接口
            , field: "uploadField"
            , accept: 'file' //普通文件
            , done: function (res) {
                //上传完毕回调
                console.log(res)
                layer.open({
                    type: 2
                    , title: 'excel解析话术'
                    , area: ['100%', '100%']
                    , shade: 0
                    , maxmin: true
                    , content: '../cdr/flowcdr?callid=excel'
                    , zIndex: layer.zIndex //重点1
                    , success: function (layero) {
                        layer.setTop(layero); //重点2
                    }
                });
            }
            , error: function () {
                //请求异常回调
            }
        });
        //执行实例
        upload.render({
            elem: '#test2' //绑定元素
            , url: '/home/importrecord' //上传接口
            , field: "uploadField"
            , accept: 'file' //普通文件
            , done: function (res) {
                //上传完毕回调
                console.log(res)
                layer.open({
                    type: 2
                    , title: '录音离线质检'
                    , area: ['100%', '100%']
                    , shade: 0
                    , maxmin: true
                    //off_line是区分离线质检的地方，off_line1是由于在首页进去的时候 ，要直接一直刷新的
                    , content: '../cdr/flowcdr?callid='+res.message+"&off_line=true&off_line1=true"
                    , zIndex: layer.zIndex //重点1
                    , success: function (layero) {
                        layer.setTop(layero); //重点2
                    }
                });
            }
            , error: function () {
                //请求异常回调
            }
        });
    });

    var count = {{.count}}
            console.log()
    var all = {{.all}}
            console.log()
    count = count / all
    if (all == 0) {
        zhuanhuang(0.00)
    } else {
        zhuanhuang(count)
    }

    function zhuanhuang(counts) {
        $("#zhuan").html(counts.toFixed(2) * 100 + "%")
        $("#zhuan1").html(counts.toFixed(2) * 100 + "%")
    }

    function failAdd() {
        if ($("#fail").val() == "") {
            layer.msg("不能为空")
            return
        }
        $.post('{{urlfor "KeywordsController.AjaxSave"}}', "content=" + $("#fail").val() + "&type=1", function (out) {
            layer.msg(out.message)
        }, "json");
    }

    function goodAdd() {
        if ($("#good").val() == "") {
            layer.msg("不能为空")
            return
        }
        $.post('{{urlfor "KeywordsController.AjaxSave"}}', "content=" + $("#good").val() + "&type=2", function (out) {
            layer.msg(out.message)
        }, "json");
    }

    function commonAdd() {
        if ($("#common").val() == "") {
            layer.msg("不能为空")
            return
        }
        $.post('{{urlfor "KeywordsController.AjaxSave"}}', "content=" + $("#common").val() + "&type=3", function (out) {
            layer.msg(out.message)
        }, "json");
    }

    function weixianTap() {
        window.location.href = "/cdr/cdr?type=1"
    }

    function liuliangTap() {
        window.location.href = "/cdr/cdr?type=2"
    }
</script>
</body>
</html>
